<template>
  <div class="wrap">
    <div class="content">
      <router-view></router-view>
    </div>
    <footer>
      <router-link v-for="(item,index) in list" :to="item.path" :key="index" class="footer">
        <div class="a">
          <van-icon :name="item.icon" />
          <span>{{item.title}}</span>
        </div>
      </router-link>
    </footer>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        {
          title: "首页",
          path: "/home/shou",
          icon: "wap-home"
        },
        {
          title: "找房",
          path: "/home/find",
          icon: "shop-collect"
        },
        {
          title: "发布",
          path: "/home/fabu",
          icon: "add-o"
        },
        {
          title: "消息",
          path: "/home/message",
          icon: "chat"
        },
        {
          title: "我的",
          path: "/home/my",
          icon: "manager"
        }
      ]
    };
  },
  created() {
    //登录成功  拿到token   不成功 返回login页面
    const token = localStorage.getItem("token");
    if (!token) {
      this.$router.push("/login");
    }
  },
  methods: {}
};
</script>

<style lang="scss">
.wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1;
  overflow-y: scroll;
}
footer {
  height: 50px;
  width: 100%;
  border-top: 1px solid #ccc;
  display: flex;
  align-content: center;
  justify-content: space-around;
  text-align: center;
  .footer {
    display: flex;
    align-items: center;
    span {
      text-align: center;
      color: #000;
      font-size: 14px;
      display: block;
    }
  }
}
.router-link-active {
  color: palevioletred;
}
</style>